{% extends 'catalog/base.html' %}

{% block content %}
<div class="col-12">
    <form method="post" enctype="multipart/form-data" class="row">
        <div class="col-6">
            <div class="card">
                <div class="card-header">
                    {% if object %}
                        <h4 class="my-0 font-weight-normal">Изменение продукта</h4>
                    {% else %}
                        <h4 class="my-0 font-weight-normal">Создание продукта</h4>
                    {% endif %}
                </div>
                <div class="card-body">

                    {% csrf_token %}
                    {{ form.as_p }}
                    <button type="submit" class="form-control btn btn-lg btn-block btn-outline-primary">
                        {% if object %}
                        Сохранить
                        {% else %}
                        Создать
                        {% endif %}
                    </button>

                </div>

            </div>
        </div>

        <div class="col-6 mb-3">
            <div class="card">
                <div class="card-header">
                    <h4 class="my-0 font-weight-normal">Версия</h4>
                </div>
                <div class="card-body">
                    {{ formset.management_form }}
                    {% for form in formset.forms %}
                    {{ form.as_p }}
                    {% if not forloop.last %}
                    <hr class="text-bg-primary p-1">
                    {% endif %}
                    {% endfor %}
                </div>
            </div>
        </div>
    </form>
</div>
{% endblock %}